# -*- encoding: utf-8 -*-
from shapely.wkt import loads as wkt_loads
import dsl
from . import FixtureTest


class MissingBuildings(FixtureTest):
    def test_best_tile(self):
        # Best Tile
        self.generate_fixtures(dsl.way(103383621, wkt_loads('POLYGON ((-122.406437119845 37.7373055819774, -122.406305067498 37.73731275712169, -122.406305696319 37.7373202164294, -122.406120912865 37.73733009113079, -122.406120194213 37.73732277390617, -122.405997035187 37.7373293807207, -122.406003503057 37.7374053945659, -122.405920139399 37.737409870145, -122.405866240482 37.73678676747259, -122.406069169905 37.73677575603398, -122.406065486812 37.73673355734449, -122.406358517258 37.73671778611099, -122.40636157153 37.73675415940128, -122.406389329472 37.7367526675284, -122.406437119845 37.7373055819774))'), {u'website': u'http://www.besttilesf.com/', u'building': u'yes', u'name': u'Best Tile', u'source': u'openstreetmap.org', u'building:levels': u'1', u'addr:postcode': u'94124', u'wheelchair': u'yes', u'way_area': u'4828.46', u'height': u'7', u'phone': u'1-415-467-8563', u'addr:housenumber': u'625', u'addr:street': u'Bayshore Boulevard', u'addr:city': u'San Francisco'}))  # noqa

        self.assert_has_feature(
            16, 10484, 25339, 'buildings',
            {'id': 103383621})

    def test_miraloma_school(self):
        # Miraloma School
        self.generate_fixtures(dsl.way(338881092, wkt_loads('POLYGON ((-122.450510623641 37.7382311698511, -122.450478374122 37.73834149511859, -122.450489064074 37.73834369735989, -122.450296016119 37.73906482129318, -122.450301406011 37.73907441160458, -122.45032548086 37.73922600939818, -122.450299968706 37.73922870888751, -122.450270503965 37.73922977447538, -122.450241668044 37.739230769024, -122.450208160884 37.73922821161317, -122.450181391089 37.73922600939818, -122.450149770391 37.73922181808569, -122.450155160283 37.73920540802928, -122.450023826588 37.73918729302778, -122.450019784169 37.7392068998528, -122.449842097406 37.73918097053597, -122.449832665096 37.73921862132179, -122.449636922195 37.7391856591255, -122.449689204145 37.73899108241331, -122.449672405649 37.73898788563939, -122.449694504205 37.7388924796345, -122.450078084831 37.73895556269539, -122.450163784109 37.73863787358088, -122.450232415397 37.7383520090441, -122.450236278153 37.73833566983489, -122.450222264434 37.7383341069539, -122.450228283147 37.73830810629129, -122.450216874543 37.73830647236959, -122.45024436299 37.7382136939726, -122.450259814013 37.7382158962177, -122.450296734771 37.73818399917779, -122.450492477672 37.7382136939726, -122.450489782726 37.73822811512467, -122.450510623641 37.7382311698511))'), {u'building': u'school', u'addr:housenumber': u'175', u'addr:city': u'San Francisco', u'building:levels': u'2', u'addr:postcode': u'94127', u'way_area': u'5707.87', u'addr:state': u'CA', u'height': u'8 m', u'source': u'openstreetmap.org', u'addr:street': u'Omar Way', u'name': u'Miraloma Elementary School'}))  # noqa

        self.assert_has_feature(
            16, 10476, 25339, 'buildings',
            {'id': 338881092})

    def test_small_building(self):
        # Tiny individual building (way_area = 5.4 sq.m.)
        self.generate_fixtures(dsl.way(278410540, wkt_loads('POLYGON ((-122.461876917099 37.7211746682194, -122.461876737436 37.72118845318148, -122.461851764271 37.72118838212499, -122.461852033766 37.72117445504979, -122.461876917099 37.7211746682194))'), {u'building': u'yes', u'source': u'openstreetmap.org', u'way_area': u'5.41175'}))  # noqa

        self.assert_has_feature(
            16, 10474, 25343, 'buildings',
            {'id': 278410540, 'min_zoom': 17})
